<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : acs562.xsl
    Created on : October 9, 2008, 4:08 PM
    Author     : alhshk
    Description:
        Purpose of transformation follows.
        
        http://www.sagehill.net/docbookxsl/CustomMethods.html#CustomizationLayer
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                version="1.0">
  <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>

<!-- <xsl:param name="html.stylesheet" select="'corpstyle.css'"/> 
<xsl:param name="admon.graphics" select="1"/> -->
  <xsl:param name="section.autolabel" select="1"/>
  <xsl:param name="section.label.includes.component.label" select="1"/>
  <xsl:param name="fop1.extensions" select="1"/>
  <xsl:param name="local.l10n.xml" select="document('')"/>
  
  <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
    <l:l10n language="en">
<!--    <l:context name="title"> 
      <l:template name="chapter" text="Chapter %n: &#8220;%t&#8221;"/> 
    </l:context>    -->
      <l:context name="title-numbered">
        <l:template name="chapter" text="%n.&#160;%t"/>
      </l:context>
    </l:l10n>
  </l:i18n>
  
  <xsl:template match="figure[processing-instruction('landscapeFigure')]">
    <fo:block-container reference-orientation="90">
      <xsl:apply-imports/>
    </fo:block-container>
  </xsl:template>

  <xsl:template name="header.content">
    <xsl:param name="pageclass" select="''"/>
    <xsl:param name="sequence" select="''"/>
    <xsl:param name="position" select="''"/>
    <xsl:param name="gentext-key" select="''"/>

    <fo:block>
    <!-- sequence can be odd, even, first, blank -->
    <!-- position can be left, center, right -->
      <xsl:choose>

        <xsl:when test="$sequence = 'blank' and $position = 'center'">
          <xsl:text>This page intentionally left blank</xsl:text>
        </xsl:when>

        <xsl:when test="$sequence = 'blank' and $position = 'right'">
        </xsl:when>

        <xsl:when test="$sequence = 'blank' and $position = 'left'">
          <fo:page-number/>
        </xsl:when>


     <!-- from default template -->
        <xsl:when test="($sequence='odd' or $sequence='even') and $position='left'">
          <xsl:if test="$pageclass != 'titlepage'">
            <xsl:choose>
              <xsl:when test="ancestor::book and ($double.sided != 0)">
                <fo:retrieve-marker retrieve-class-name="section.head.marker"
                                  retrieve-position="first-including-carryover"
                                  retrieve-boundary="page-sequence"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="." mode="titleabbrev.markup"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:if>
        </xsl:when>

        <xsl:when test="$sequence = 'odd' and $position = 'right'">
          <fo:retrieve-marker retrieve-class-name="section.head.marker"
                            retrieve-position="first-including-carryover"
                            retrieve-boundary="page-sequence"/>
        </xsl:when>

        <xsl:when test="$sequence = 'odd' and $position = 'center'">
          <xsl:call-template name="draft.text"/>
        </xsl:when>

        <xsl:when test="$sequence = 'odd' and $position = 'right'">
          <fo:page-number/>
        </xsl:when>

<!--      <xsl:when test="$sequence = 'even' and $position = 'left'">
        <fo:page-number/>
      </xsl:when>-->

        <xsl:when test="$sequence = 'even' and $position = 'center'">
          <xsl:call-template name="draft.text"/>
        </xsl:when>

        <xsl:when test="$sequence = 'even' and $position = 'right'">
          <xsl:apply-templates select="." mode="titleabbrev.markup"/>
        </xsl:when>

        <xsl:when test="$sequence = 'first' and $position = 'left'">
        </xsl:when>

        <xsl:when test="$sequence = 'first' and $position = 'right'">
        </xsl:when>

        <xsl:when test="$sequence = 'first' and $position = 'center'">
          <xsl:value-of
               select="ancestor-or-self::book/bookinfo/corpauthor"/>
        </xsl:when>

      </xsl:choose>
    </fo:block>
  </xsl:template>


  <xsl:template name="orig_header.content">
    <xsl:param name="pageclass" select="''"/>
    <xsl:param name="sequence" select="''"/>
    <xsl:param name="position" select="''"/>
    <xsl:param name="gentext-key" select="''"/>

<!--
  <fo:block>
    <xsl:value-of select="$pageclass"/>
    <xsl:text>, </xsl:text>
    <xsl:value-of select="$sequence"/>
    <xsl:text>, </xsl:text>
    <xsl:value-of select="$position"/>
    <xsl:text>, </xsl:text>
    <xsl:value-of select="$gentext-key"/>
  </fo:block>
-->

    <fo:block>

    <!-- sequence can be odd, even, first, blank -->
    <!-- position can be left, center, right -->
      <xsl:choose>
        <xsl:when test="$sequence = 'blank'">
        <!-- nothing -->
        </xsl:when>

        <xsl:when test="$position='left'">
        <!-- Same for odd, even, empty, and blank sequences -->
          <xsl:call-template name="draft.text"/>
        </xsl:when>

        <xsl:when test="($sequence='odd' or $sequence='even') and $position='center'">
          <xsl:if test="$pageclass != 'titlepage'">
            <xsl:choose>
              <xsl:when test="ancestor::book and ($double.sided != 0)">
                <fo:retrieve-marker retrieve-class-name="section.head.marker"
                                  retrieve-position="first-including-carryover"
                                  retrieve-boundary="page-sequence"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="." mode="titleabbrev.markup"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:if>
        </xsl:when>

        <xsl:when test="$position='center'">
        <!-- nothing for empty and blank sequences -->
        </xsl:when>

        <xsl:when test="$position='right'">
        <!-- Same for odd, even, empty, and blank sequences -->
          <xsl:call-template name="draft.text"/>
        </xsl:when>

        <xsl:when test="$sequence = 'first'">
        <!-- nothing for first pages -->
        </xsl:when>

        <xsl:when test="$sequence = 'blank'">
        <!-- nothing for blank pages -->
        </xsl:when>
      </xsl:choose>
    </fo:block>
  </xsl:template>

  <!-- front coverpage layout -->
<!--  <xsl:template name="front.cover">
    <xsl:variable name="id">
      <xsl:call-template name="object.id"/>
    </xsl:variable>
    <fo:page-sequence master-reference="front-cover" force-page-count="no-force">
      <fo:flow flow-name="xsl-region-body">
        <fo:block/>
      </fo:flow>
    </fo:page-sequence>
  </xsl:template> -->

  <!-- add our front coverpage -->
<!--  <xsl:template name="user.pagemasters">
    <xsl:param name="front-cover.path">
      <xsl:value-of select="normalize-space(//bookinfo//imagedata[@role='frontcover']/@fileref)"/>
    </xsl:param>
    <fo:simple-page-master master-name="front-cover"
                                             page-width="{$page.width}"
                                             page-height="{$page.height}"
                                             margin-top="0pt"
                                             margin-bottom="0pt"
                                             margin-left="0pt"
                                             margin-right="0pt">
      <fo:region-body margin-bottom="0pt"
                                        column-gap="{$column.gap.titlepage}"
                                        column-count="{$column.count.titlepage}"
                                background-image="url({$front-cover.path})"/>
    </fo:simple-page-master>
  </xsl:template>-->
</xsl:stylesheet>
